#include <stdio.h>
#include <malloc.h>

struct stack_record {
    unsigned int stack_size;
    int top_of_stack;
    int *stack_array;
};

typedef struct stack_record *STACK;

#define EMPTY_TOS (-1) /* Signifies an empty stack */
#define MIN_STACK_SIZE 1

void error(char *str) {
}

void fatal_error(char *str) {
}

STACK create_stack(unsigned int max_elements) {
    STACK S;
    if (max_elements < MIN_STACK_SIZE) {
        error("Stack size is too small");
    }
    S = (STACK) malloc(sizeof(struct stack_record));
    if (S == NULL) {
        fatal_error("Out of space!!!");
    }
    S->stack_array = (int *) malloc(sizeof(int) * max_elements);
    if (S->stack_array == NULL) {
        fatal_error("Out of space!!!");
    }
    S->top_of_stack = EMPTY_TOS;
    S->stack_size = max_elements;
    return (S);
}

void dispose_stack(STACK S) {
    if (S != NULL) {
        free(S->stack_array);
        free(S);
    }
}

int is_empty(STACK S) {
    return (S->top_of_stack == EMPTY_TOS);
}

void make_null(STACK S) {
    S->top_of_stack = EMPTY_TOS;
}

int is_full(STACK S) {
    return (S->top_of_stack == (S->stack_size - 1));
}

void push(int x, STACK S) {
    if (is_full(S)) {
        error("Full stack");
    } else {
        S->stack_array[++S->top_of_stack] = x;
    }
}

int top(STACK S) {
    if (is_empty(S)) {
        error("Empty stack");
    } else {
        return S->stack_array[S->top_of_stack];
    }
}

void pop(STACK S) {
    if (is_empty(S)) {
        error("Empty stack");
    } else {
        S->top_of_stack--;
    }
}

int pop_rt(STACK S) {
    if (is_empty(S)) {
        error("Empty stack");
    } else {
        return S->stack_array[S->top_of_stack--];
    }
}

int main() {
    printf("Hello, World!\n");
    return 0;
}
